<!--
 * @Author: wangshiyang
 * @Date: 2023-06-15 16:14:50
 * @LastEditors: wangshiyang
 * @LastEditTime: 2023-06-15 16:16:55
 * @Description: 请填写简介
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.css" rel="stylesheet">
    <script src="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.js"></script>
    <script src="https://lib.baomitu.com/jquery/3.6.0/jquery.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #map {
            width: 100vw;
            height: 100vh;
        }

        #select {
            position: absolute;
            z-index: 100;
            left: 10;
            top: 10;
        }
    </style>
</head>

<body>
    <select id="select">
        <option value="streets-v11">街景</option>
        <option value="satellite-v9">卫星</option>
        <option value="dark-v10">黑夜</option>
    </select>
    <div id="map">

    </div>
    <script type="module">
        /* 设置token */
        const token = 'pk.eyJ1IjoiY2hlbmdjaGFvODg2NiIsImEiOiJjbGh6b2xuNGwxN3NuM2ZwMHE4anVqcG1wIn0.5rIBvugCbCQxYCCYJQEsfA';
        mapboxgl.accessToken = token;
        const map = new mapboxgl.Map({
            container: "map",
            style: "mapbox://styles/mapbox/streets-v11",
            center: [114, 30],
            zoom: 13,
            pitch: 45,
            bearing: 20
        })
        $("#select").change((e) => {
            const value = e.target.value;
            map.setStyle(`mapbox://styles/mapbox/${value}`) //设置样式
        })
    </script>
</body>

</html>